/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 *
 */

import { ArktSTaskConst } from '../../const/common-const.js';
import { resolveHookDependency } from '../../utils/task-util.js';
import { TaskNames } from '../common/task-names.js';
import { AbstractModuleHookTask } from '../hook/abstract-module-hook-task.js';
import { ModuleTaskService } from '../service/module-task-service.js';
import { TargetTaskService } from '../service/target-task-service.js';

/**
 * 单元测试构建任务
 *
 * @since 2023/4/23
 */
export class UnitTestBuild extends AbstractModuleHookTask {
  constructor(moduleTaskService: ModuleTaskService, isFaMode: boolean) {
    super(moduleTaskService, isFaMode, TaskNames.Task.UNIT_TEST_BUILD);
  }

  initTaskDepends(taskTargetService: TargetTaskService): void {
    const name = this._isFaMode ? ArktSTaskConst.LEGACY_UNIT_TEST_ARKTS : ArktSTaskConst.UNIT_TEST_ARKTS;
    this.dependsOn(resolveHookDependency(name, taskTargetService.getTargetData().getTargetName()));
  }
}
